package com.gyz.cfmall.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author gong_yz
 * @Description 视图控制器将请求与页面进行绑定
 * @Date 2023/4/6 14:54
 */
@Configuration
public class CfMallWebConfig implements WebMvcConfigurer {

    /**
     * 视图映射:发送一个请求，直接跳转到一个页面
     *
     * @GetMapping("/login.html")
     * public String loginPage(){
     *     return "login";
     * }
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // @GetMapping("/login.html") -> "/login.html"
        // return "login" -> "login"
//        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/reg.html").setViewName("reg");
    }
}
